import time

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver=webdriver.Chrome()
# driver=webdriver.Firefox()
driver.get('http://101.133.169.100/yuns/index.php')

time.sleep(3)
driver.maximize_window()#设置窗体最大化
driver.find_element_by_xpath('//*[@class="but1"]').send_keys('手机')
driver.find_element_by_xpath('//*[@class="but1"]').send_keys(Keys.ENTER)
driver.find_element_by_xpath('//*[@class="but1"]').send_keys('苹果')
#shurk=driver.find_element_by_xpath('//*[@class="but1"]').get_attribute('value')#把输入框的值先保存下来

driver.find_element_by_xpath('//*[@class="but1"]').send_keys(Keys.CONTROL,'a')#模拟键盘全选
driver.find_element_by_xpath('//*[@class="but1"]').send_keys(Keys.CONTROL,'c')#模拟键盘剪切
time.sleep(2)

#driver.find_element_by_xpath('//*[@class="but1"]').send_keys(shurk)#把之前保存的值发送到输入框
# time.sleep(2)
driver.find_element_by_xpath('//*[@class="but1"]').send_keys(Keys.RIGHT,'')
driver.find_element_by_xpath('//*[@class="but1"]').send_keys(Keys.CONTROL,'v')#在输入框本身有值的情况下，继续粘贴之前的值
time.sleep(3)
driver.quit()
